import torch

try:
    import torch_npu
    print(f"PyTorch Version: {torch.__version__}")
    print(f"Is torch_npu available? {'torch_npu' in torch.backends.quantized.supported_engines}")

    is_npu_available = torch.npu.is_available()
    print(f"Is NPU available via torch.npu.is_available()? {is_npu_available}")

    if is_npu_available:
        print(f"NPU Device Count: {torch.npu.device_count()}")
        print(f"Current NPU Device: {torch.npu.current_device()}")
        print(f"NPU Device Name: {torch.npu.get_device_name(0)}")
    else:
        print("NPU not available. Please check your torch_npu installation and CANN driver compatibility.")
except ImportError:
    print("torch_npu is not installed. Please follow AutoDL's guide to install the correct version.")
except Exception as e:
    print(f"An error occurred: {e}") 